package com.ytrsoft.task;

import com.ytrsoft.bean.Action;
import com.ytrsoft.ws.BaseSocket;
import com.ytrsoft.ws.CmdSocket;
import com.ytrsoft.ws.IdeaSocket;

public class ActionFactory<T extends BaseSocket> {

    private final T socket;

    public ActionFactory(T socket) {
        this.socket = socket;
    }

    public ActionHandler createHandler(Action action) {
        if (action == Action.RUN) {
            return new RunHandler(socket);
        }
        if (action == Action.PROCESS) {
            return new ProcessHandler((CmdSocket) socket);
        }
        if (action == Action.INPUT) {
            return new InputHandler((IdeaSocket) socket);
        }
        return new DefaultHandler();
    }

}
